Uec3.StoreListWindow = Ext.extend(Ext.app.Module, {
    id: 'store_list',
    objsCollection:new Ext.util.MixedCollection(true),
    getObjByKey:function(key){
		return this.objsCollection.get(key);
	},
    view:function(id){
    	var store=this.getObjByKey("store");
    	var choose=this.getObjByKey("choose");
    	var obj=store.getById(id).data;
		choose(obj);
    },
    getPanel:function() {
    	var module=this;
    	var store_colModel = new Ext.grid.ColumnModel([
			new Ext.grid.RowNumberer(),	
			{
			header : "操作",
			width : 35,
			dataIndex : 'id',
            renderer:function(value,meta,record,rowIndex,colIndex,store){
            	var str="<a style='font-size:12px' href='javascript:Ext.CUR_APP.getModule(\""+module.id+"\").view("+record.id+");'>选中</a>"
            	return str;
            }
			},{   
			header : "companyId",
			width : 60,
			dataIndex : 'companyId',
            hidden:true
		   },{
			header : "仓库名称",
			width :80,
			sortable : true,
			dataIndex : 'name'
		   },{
			header : "部门",
			width : 80,
			dataIndex : 'departmentName'			
		   },{
			header : "创建时间",
			width : 100,
			renderer : Ext.util.Format.dateRenderer('Y-m-d'),
			dataIndex : 'gmtCreate'
		   },{
			header : "修改时间",
			width : 100,
			renderer : Ext.util.Format.dateRenderer('Y-m-d'),
			dataIndex : 'gmtModify'
		   }]);
		var store_ds = new Ext.data.Store({
			proxy:new Ext.data.HttpProxy({url : Uec3.App.Constants.homeUrl+'/store/base!query.do'}),
			baseParams:{start: 0,limit:10},
		    paramNames : {
				start : "start",
				limit : "limit",
				sort : "sort",
				dir : "dir"
			},
			reader : new Ext.data.JsonReader({
				totalProperty: 'totalProperty',
	            root: 'root'
            },
            [{
				name:'id'
			},{
				name:'companyId'
			},{
				name:'pyCode'
			},{
				name : 'departmentId'
			},{
				name : 'departmentName'
			},{
				name : 'name'
			},{
				name : 'gmtCreate',
				type : 'date',
				dateFormat:'Y-m-d H:i:s'
			},{
				name : 'gmtModify',
				type : 'date',
				dateFormat:'Y-m-d H:i:s'
			}]), 
		   listeners:{
				'load':function(){
					
				}
			},
			remoteSort:true,			
			sortInfo :{field: "id",direction:"asc"}			
		});
		module.objsCollection.add("store",store_ds);
		var store_grid = new Ext.grid.GridPanel({
			region: 'center',
			iconCls : 'icon-grid',
			enableColumnMove:false,
			enableColumnMoveResize:false,
			stripeRows:true,
			//hight:240,
			loadMask:{msg:"...加载数据中"},
			store :store_ds,
			cm:store_colModel,
			sm: new Ext.grid.RowSelectionModel({
				singleSelect:true
			}),
			viewConfig :{
				forceFit : true,
				columnsText:'显示的列',
				scrollOffset:10,
				sortAscText:'升序',
				sortDescText:'降序'
			},
			bbar: new Ext.PagingToolbar({
				pageSize:10,
				store:store_ds,
				display: true,
				displayInfo: true,
				displayMsg: '第 {0} - {1} 条  共 {2} 条',
				emptyMsg: "没有记录"       
			}),
			listeners:{
				'rowdblclick':function(grid,rowIndex){
					var obj=store_grid.getStore().getAt(rowIndex).data;
					choose(obj);
				}
			}
		});
		store_ds.load();
		
	var choose=function(obj){
		module.setLookupValue({id:obj.id,name:obj.name,pyCode:obj.pyCode},store_grid.ownerCt);
		store_grid.ownerCt.close();		
	}
	module.objsCollection.add("choose",choose);
	return store_grid;
	},
    createWindow : function(params){
   	  var windowId=this.id;
   	  if(params){
   	  	windowId+=Ext.isEmpty(params.winId)?"":"_"+params.winId;
   	  }
      var desktop = Uec3.App.getDesktop();
      var module=this;
      var win = desktop.getWindowByUecId(windowId);
      if(!win){
         win = desktop.createWindow({
            uecId:windowId,
            title: module.launcher.text,
			width:600,
			height:330,
			collapsible:true,
			constrait:true,
			modal:true,
			draggable:true,
			plain:true,
			header:true,
            resizable:false,
            layout: "fit", 
            items:[module.getPanel()],
            listeners:{
            	'resize':function(win,width,height){
            	}
            }
    	});
    } 
    win.show();
    }
});